package cn.ztuo.bitrade.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.ztuo.bitrade.constant.BooleanEnum;
import cn.ztuo.bitrade.constant.CommonStatus;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @author MrGao
 * @description
 * @date 2017/12/29 14:14
 */
@Entity
@Data
@Table(name = "coin")
@ToString
public class Coin {
    @Id
    @NotBlank(message = "币名称不得为空")
    @Excel(name = "货币", orderNum = "1", width = 20)
    private String name;
    /**
     * 中文
     */
    @Excel(name = "中文名称", orderNum = "1", width = 20)
    @NotBlank(message = "中文名称不得为空")
    private String nameCn;
    /**
     * 缩写
     */
    @Excel(name = "单位", orderNum = "1", width = 20)
    @NotBlank(message = "单位不得为空")
    private String unit;
    /**
     * 状态
     */
    @Enumerated(EnumType.ORDINAL)
    private CommonStatus status = CommonStatus.NORMAL;

    /**
     * 最小提币手续费
     */
    @Excel(name = "最小提币手续费", orderNum = "1", width = 20)
    private double minTxFee;
    /**
     * 对人民币汇率
     */
    @Excel(name = "对人民币汇率", orderNum = "1", width = 20)
    @Column(columnDefinition = "decimal(18,8) default 0.00 comment '人民币汇率'")
    private BigDecimal cnyRate;
    /**
     * 最大提币手续费
     */
    @Deprecated
    @Excel(name = "最大提币手续费", orderNum = "1", width = 20)
    private double maxTxFee;
    /**
     * 对美元汇率
     */
    @Excel(name = "对美元汇率", orderNum = "1", width = 20)
    @Column(columnDefinition = "decimal(18,8) default 0.00 comment '美元汇率'")
    private BigDecimal usdRate;
    /**
     * 对新加坡币汇率
     */
    @Excel(name = "对新加坡币汇率", orderNum = "1", width = 20)
    @Column(columnDefinition = "decimal(18,2) default 0.00 comment '美元汇率'")
    private BigDecimal sgdRate;

    /**
     * 是否支持rpc接口
     */
    @Enumerated(EnumType.ORDINAL)
    private BooleanEnum enableRpc = BooleanEnum.IS_TRUE;

    /**
     * 排序
     */
    private int sort=10;

    /**
     * 是否能提币
     */
    @Enumerated(EnumType.ORDINAL)
    private BooleanEnum canWithdraw=BooleanEnum.IS_TRUE;

    /**
     * 是否能充币
     */
    @Enumerated(EnumType.ORDINAL)
    private BooleanEnum canRecharge=BooleanEnum.IS_TRUE;


    /**
     * 是否能转账
     */
    @Enumerated(EnumType.ORDINAL)
    private BooleanEnum canTransfer = BooleanEnum.IS_TRUE;

    /**
     * 是否能自动提币
     */
    @Enumerated(EnumType.ORDINAL)
    private BooleanEnum canAutoWithdraw=BooleanEnum.IS_FALSE;

    /**
     * 提币阈值
     */
    @Column(columnDefinition = "decimal(18,8) comment '自动提现阈值'")
    private BigDecimal withdrawThreshold;
    @Column(columnDefinition = "decimal(18,8) comment '最小提币数量'")
    private BigDecimal minWithdrawAmount;
    @Column(columnDefinition = "decimal(18,8) comment '最大提币数量'")
    private BigDecimal maxWithdrawAmount;

    /**
     * 是否是平台币
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(columnDefinition = "int default 0 comment '是否为平台币'")
    private BooleanEnum isPlatformCoin = BooleanEnum.IS_FALSE;

    /**
     * 是否是法币
     */
    @Column(name = "has_legal", columnDefinition = "bit default 0", nullable = false)
    private Boolean hasLegal = false;

    @Transient
    private BigDecimal allBalance ;

    private String coldWalletAddress ;

    @Transient
    private BigDecimal hotAllBalance ;

    /**
     * 转账时付给矿工的手续费
     */
    @Column(columnDefinition = "decimal(18,8) default 0 comment '矿工费'")
    private BigDecimal minerFee = BigDecimal.ZERO;

    @Column(columnDefinition = "int default 4 comment '提币精度'")
    private int withdrawScale;

    @Column(columnDefinition = "decimal(18,8) default 0 comment '最小充币数量'")
    private BigDecimal minRechargeAmount = BigDecimal.ZERO;

    @Column(columnDefinition = "varchar(64) default null comment '主充值地址'")
    private String masterAddress;

    @Column(columnDefinition = "decimal(18,8) default 0 comment '单日最大提币量'")
    private BigDecimal maxDailyWithdrawRate=BigDecimal.ZERO;
}
